package cloud.xiguapi.ubas.analysis.hotitems.model;

import cloud.xiguapi.ubas.model.UserBehavior;
import org.apache.flink.api.common.functions.AggregateFunction;

/**
 * @author 大大大西西瓜皮🍉
 * date: 2021-5-18 下午 05:11
 * desc:
 */
public class KafkaHotItemsCountAggregate implements AggregateFunction<UserBehavior, Long, Long> {

    @Override
    public Long createAccumulator() {
        return 0L;
    }

    @Override
    public Long add(UserBehavior value, Long accumulator) {
        return accumulator + 1;
    }

    @Override
    public Long getResult(Long accumulator) {
        return accumulator;
    }

    @Override
    public Long merge(Long a, Long b) {
        return a + b;
    }
}